﻿using Microsoft.Practices.Unity;
using TestWebApplication.Models.Config;
using TestWebApplication.Models.DataAccess;

namespace TestWebApplication.Models
{
    public static class ContainerFactory
    {
        public static IUnityContainer Create()
        {
            var configManager = ConfigManager.GetInstance();

            return new UnityContainer()
                .RegisterType<IAuthService, AuthService>()
                .RegisterType<IStorage, DbStorage>()
                .RegisterType<INotificationService, EmailNotificationService>()
                .RegisterType<DbStorage>(new InjectionConstructor(configManager.ConnectionString))
                .RegisterInstance(configManager.EmailNotificationServiceServiceConfig)
                .RegisterInstance("GenerateServerExceptionMode", configManager.GenerateServerExceptionMode);
        }

    }
}